<?php if(!defined('THINK_PATH')) exit('Access Denied');
class CacheAction extends SakuraAction {
    public function __construct(){
    	parent::__construct();
    }
    public function GetCache($key){
    	$Model = M('Cache');
    	$data = $Model->where("`key`='".$key."'")->select();
    	if(!$data) $Model->add(array('key'=>$key,'value'=>'0'));
    	$data = $Model->where("`key`='".$key."'")->select();
    	return $data['0']['value'];
    }
    public function SetCache($key,$value){
    	$Model = M('Cache');
    	$data = $Model->where("`key`='".$key."'")->select();
    	if(!$data) $Model->add(array('key'=>$key,'value'=>$value));
    	else $Model->where("`key`='".$key."'")->save(array('value'=>$value));
    }
}